<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:comps="http://java.sun.com/jsf/composite/components">
	
<h:form id="criarBlogForm">
	
	<p:panel
		header="Manuntencao do Blog"
		rendered="#{SessaoBean.usuarioAutenticado.blog == null}">
			
		<h:panelGroup layout="block" style="padding: 100px; text-align: center;">
	
			<p:commandButton id="criarBlogBtn"
				styleClass="ui-priority-primary"
				style="font-size: 3em !important;"
				value="#{locale['blog.botao.criarBlog']}"
				update="criarBlogForm"
				action="#{UsuarioBlogBean.prepararCadastroBlog()}" />
			
		</h:panelGroup>
				
	</p:panel>
	
	<p:panel
		header="Manuntencao do Blog"
		rendered="#{SessaoBean.usuarioAutenticado.blog != null}">
			
		<h:panelGroup layout="block" style="text-align: center;">
	
			<h:form id="edicaoBlogForm">
						
				<h:panelGroup layout="block" styleClass="cadastroMessages">
					<p:messages id="cadastroBlogMessages" />
				</h:panelGroup>
							
				<h:panelGrid columns="2">
		
					<p:outputLabel id="nomeEdcLbl" style="font-weight: bold;" 
						for="nomeEdc" value="#{locale['blog.label.nome']}" />
					<p:inputText id="nomeEdc" value="#{UsuarioBlogBean.blog.nome}"
						label="#{locale['blog.label.nome']}"
						onkeypress="limparEspacosExtras(this);"
						onblur="trim(this);"
						style="width: 500px; padding: 10px;"
						maxlength="100"
						required="true"
						readonly="true"
						disabled="true">
					</p:inputText>
					
					<p:outputLabel id="tituloEdcLbl" style="font-weight: bold;" 
						for="tituloEdc" value="#{locale['blog.label.titulo']}" />
					<p:inputText id="tituloEdc" value="#{UsuarioBlogBean.blog.titulo}"
						label="#{locale['blog.label.titulo']}"
						onkeypress="limparEspacosExtras(this);"
						onblur="trim(this);"
						style="width: 500px; padding: 10px;"
						maxlength="100"
						required="true">
					</p:inputText>
					
					<p:outputLabel id="descricaoEdcLbl" style="font-weight: bold;" 
						for="descricaoEdc" value="#{locale['blog.label.descricao']}" />
					<p:inputTextarea id="descricaoEdc" value="#{UsuarioBlogBean.blog.descricao}"
						label="#{locale['blog.label.titulo']}"
						onkeypress="limparEspacosExtras(this);"
						onblur="trim(this);"
						style="width: 500px; padding: 10px;"
						counterTemplate="#{locale['crud.mensagens.caracteresRestantes']}"
						counter="contadorDescricao"
						maxlength="255"
						required="true" />			
						
					<p:spacer />
					<h:panelGroup layout="block" 
						style="text-align: right; margin-bottom: 5px; font-size: 0.8em;">
						<h:outputText id="contadorDescricao" />
					</h:panelGroup>		
					
					<p:outputLabel id="assuntosEdcLbl" style="font-weight: bold;" 
						for="assuntosEdc" value="#{locale['blog.label.assuntos']}" />
					<p:inputTextarea id="assuntosEdc" value="#{UsuarioBlogBean.blog.assuntos}"
						label="#{locale['blog.label.titulo']}"
						onkeypress="limparEspacosExtras(this);"
						onblur="trim(this);"
						style="width: 500px; padding: 10px;"
						counterTemplate="#{locale['crud.mensagens.caracteresRestantes']}"
						counter="contadorAssuntos"
						maxlength="255"
						required="true" />			
						
					<p:spacer />
					<h:panelGroup layout="block" 
						style="text-align: right; margin-bottom: 5px; font-size: 0.8em;">			
						<h:outputText id="contadorAssuntos" />
					</h:panelGroup>
								
				</h:panelGrid>
				
				<h:panelGroup layout="block" style="text-align: right; margin-top: 10px;">
					
					<p:commandButton id="salvarEdc" value="#{locale['cadastro.botao.atualizar']}"
						icon="ui-icon-disk"
						styleClass="ui-priority-primary"
						action="#{UsuarioBlogBean.atualizarBlog()}"
						update="edicaoBlogForm" />
									
				</h:panelGroup>
							
			</h:form>
			
		</h:panelGroup>
				
	</p:panel>	
	
</h:form>

<p:dialog id="criarBlogDialogo"
	position="500,80"
	resizable="false" closable="false" draggable="false"
	widgetVar="criarBlogDlg"
	showEffect="slide" hideEffect="slide"
	modal="true">
				
	<f:facet name="header">
		<h:outputText value="Criar meu blog" />
	</f:facet>
				
	<h:form id="cadastroBlogForm">
				
		<h:panelGroup layout="block" styleClass="cadastroMessages">
			<p:messages id="cadastroBlogMessages" />
		</h:panelGroup>
					
		<h:panelGrid columns="2">

			<p:outputLabel id="nomeInsLbl" style="font-weight: bold;" 
				for="nomeIns" value="#{locale['blog.label.nome']}" />
			<p:inputText id="nomeIns" value="#{UsuarioBlogBean.blog.nome}"
				label="#{locale['blog.label.nome']}"
				onkeypress="limparEspacosExtras(this);"
				onblur="trim(this);"
				style="width: 400px;"
				maxlength="100"
				required="true">
			</p:inputText>
			
			<p:outputLabel id="tituloInsLbl" style="font-weight: bold;" 
				for="tituloIns" value="#{locale['blog.label.titulo']}" />
			<p:inputText id="tituloIns" value="#{UsuarioBlogBean.blog.titulo}"
				label="#{locale['blog.label.titulo']}"
				onkeypress="limparEspacosExtras(this);"
				onblur="trim(this);"
				style="width: 400px;"
				maxlength="100"
				required="true">
			</p:inputText>
			
			<p:outputLabel id="descricaoInsLbl" style="font-weight: bold;" 
				for="descricaoIns" value="#{locale['blog.label.descricao']}" />
			<p:inputTextarea id="descricaoIns" value="#{UsuarioBlogBean.blog.descricao}"
				label="#{locale['blog.label.titulo']}"
				onkeypress="limparEspacosExtras(this);"
				onblur="trim(this);"
				style="width: 400px;"
				counterTemplate="#{locale['crud.mensagens.caracteresRestantes']}"
				counter="contadorDescricao"
				maxlength="255"
				required="true" />			
				
			<p:spacer />
			<h:panelGroup layout="block" 
				style="text-align: right; margin-bottom: 5px; font-size: 0.8em;">
				<h:outputText id="contadorDescricao" />
			</h:panelGroup>		
			
			<p:outputLabel id="assuntosInsLbl" style="font-weight: bold;" 
				for="assuntosIns" value="#{locale['blog.label.assuntos']}" />
			<p:inputTextarea id="assuntosIns" value="#{UsuarioBlogBean.blog.assuntos}"
				label="#{locale['blog.label.titulo']}"
				onkeypress="limparEspacosExtras(this);"
				onblur="trim(this);"
				style="width: 400px;"
				counterTemplate="#{locale['crud.mensagens.caracteresRestantes']}"
				counter="contadorAssuntos"
				maxlength="255"
				required="true" />			
				
			<p:spacer />
			<h:panelGroup layout="block" 
				style="text-align: right; margin-bottom: 5px; font-size: 0.8em;">			
				<h:outputText id="contadorAssuntos" />
			</h:panelGroup>
						
		</h:panelGrid>
		
		<h:panelGroup layout="block" 
			style="text-align: right; margin-top: 10px; border-top: dotted 1px; padding-top: 10px;">
			
			<p:commandButton id="salvarIns" value="#{locale['crud.botao.salvar']}"
				icon="ui-icon-disk"
				styleClass="ui-priority-primary left"
				action="#{UsuarioBlogBean.salvarBlog()}"
				update="cadastroBlogForm" />
					
			<p:commandButton id="cancelarIns" value="#{locale['crud.botao.cancelar']}"
				icon="ui-icon-close"
				action="#{UsuarioBlogBean.cancelarCadastroBlog()}"
				immediate="true"
				update="cadastroBlogForm" />
							
		</h:panelGroup>
					
	</h:form>
			
</p:dialog>

</ui:composition>